package com.zzh.weixinsell.dao;

import com.zzh.weixinsell.model.pojo.ProductInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface ProductInfoMapper {


    int insert(ProductInfo productInfo);

    @Select("select * from product_info where product_status = #{product_status}")
    List<ProductInfo> findByProductStatus(@Param("product_status") Integer productStatus);

    @Insert("INSERT INTO `wechat_order_system`.`product_info` " +
            "(`product_id`, `product_name`, `product_price`, `product_stock`, `product_description`, `product_icon`, `product_status`, `category_type`)" +
            " VALUES (#{product_id}, #{product_name}, #{product_price}, #{product_stock}, #{product_description}, #{product_icon}, #{product_status}, #{category_type})")
    int insertOne(@Param("product_id")String product_id,@Param("product_name")String product_name,@Param("product_price")Integer product_price,
               @Param("product_stock")Integer product_stock,@Param("product_description")String product_description,@Param("product_icon")String product_icon,
               @Param("product_status")Integer product_status,@Param("category_type")Integer category_type);

    @Select("select * from product_info where product_status = #{product_status}")
    List<ProductInfo> findUpAll();

    @Select("select * from product_info where product_id = #{product_id}")
    ProductInfo findOne(@Param("product_id")String product_id);

    int updateByPrimaryKey(ProductInfo record);



}